
var opacity = 0.3;

var teamsInfo = {
	1: { color: "#ff0000", colorA: "rgba(100%, 0%, 0%, "+opacity+")", bag: "bag_red.png" },
	2: { color: "#0000ff", colorA: "rgba(0%, 0%, 100%, "+opacity+")", bag: "bag_blue.png"  },
	3: { color: "#00ff00", colorA: "rgba(0%, 100%, 0%, "+opacity+")", bag: "bag_green.png"  },
	4: { color: "#ffff00", colorA: "rgba(100%, 100%, 0%, "+opacity+")", bag: "bag_yellow.png"  },
	5: { color: "#ff00ff", colorA: "rgba(100%, 0%, 100%, "+opacity+")", bag: "bag_purple.png"  },
	6: { color: "#00ffff", colorA: "rgba(0%, 100%, 100%, "+opacity+")", bag: "bag_red.png"  },
}

function openPlayersPage(){
	$("#players_table").empty();
	var cX = 260*scale, cY = 500*scale, radius = 230*scale; 
	var x, y = 0;
	var step = Math.PI / teams.length;
	var curStep = -Math.PI / 2;

	for (var i = 0; i < teams.length*2; i++) {
		x = cX + radius*Math.cos(curStep);
		y = cY + radius*Math.sin(curStep);
		var indexTeam = i % teams.length;
		var playerName = teams[indexTeam].players[ Math.floor(i / teams.length) ];
		indexTeam = teams[indexTeam].index;
		if(i == 0) y -= 40*scale;
		if(i == teams.length) y += 40*scale;
		$("#players_table").append('<div style="left: '+x+'px; top: '+y+'px; '+
				'background-color: '+teamsInfo[ indexTeam ].colorA+';" class="player_box">'+
				'<div style="background-color: '+teamsInfo[ indexTeam ].color+';" class="team_index active">'+indexTeam+'</div>'+
				'<span>'+playerName+'</span></div>');		
		curStep += step;
	}
	openPage('players_page');
}

$(document).ready(function() {
	$("#players_btn_back").click(function(){
		openEditWordsPage(true);
		//openEnterPlayersPage();
	});
	
	$("#players_btn_1tur").click(function(){
		openGamePage(true);
	});
	
});
